package com.example.drugs1.services;

import com.example.drugs1.dao.DrugsRepository;
import com.example.drugs1.entities.Drugs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DrugsService {

    @Autowired
    DrugsRepository drugsRepository;

    public Drugs save(Drugs drugs){return drugsRepository.save(drugs);}

    public List<Drugs> getALL(){return drugsRepository.findAll();}

    public Drugs findByDugsId(long theId){

        return drugsRepository.findByDrugsId(theId);
    }

    public List<Drugs> selectDrugs(String theName){
        return drugsRepository.selectDrugs(theName);
    }

    public void delete(Drugs theDrugs){

        drugsRepository.delete(theDrugs);
    }
}
